package com.yunhe.mybatis.web.deparment;

import com.yunhe.mybatis.entity.Deparment;
import com.yunhe.mybatis.service.impl.DeparmentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deparment/save")
public class SaveServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String bumen = req.getParameter("bumen");

        DeparmentServiceImpl deparmentService = new DeparmentServiceImpl();
        Deparment deparment = new Deparment();
        deparment.setName(bumen);
        deparmentService.save(deparment);
        req.getRequestDispatcher("/success.jsp").forward(req,resp);
    }
}
